<template>
	<view>
		<view class="zx_version" @click="versionDoubleClick" @longpress="versionLongpress">
			Copyright © 2020 {{version}}
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				version: "v3.2009.1716",
				touchEndTime:0,
				touchStartTime:0,
				
			};
		},
		methods: {
			versionLongpress:function(e){
				console.log("versionLongpress 长按事件",e);
			},
			/// 双击
			versionDoubleClick: function(e) {
				var that = this
				console.log("versionDoubleClick",e);
				// 控制点击事件在350ms内触发，加这层判断是为了防止长按时会触发点击事件
				if (that.touchEndTime - that.touchStartTime < 350) {
					// 当前点击的时间
					var currentTime = e.timeStamp
					var lastTapTime = that.lastTapTime
					// 更新最后一次点击时间
					that.lastTapTime = currentTime

					// 如果两次点击时间在300毫秒内，则认为是双击事件
					if (currentTime - lastTapTime < 300) {
						console.log("double tap");
						console.log('双击事件已触发');
						uni.clearStorageSync();
						uni.showToast({
							title:"缓存已清除"
						});
					}
				}
			},
		}
	}
</script>

<style>
	.zx_version {
		font-size: 20rpx;
		text-align: center;
		padding: 40rpx;
		color: #999999;
	}
</style>
